var weakArr, dates
weakArr = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
var date = new Date()
year = date.getFullYear()
month = date.getMonth() + 1
dates = date.getDate()
day = date.getDay()
document.getElementById("nowTime").innerHTML = year + "年" + month + "月" + dates + "日 \t" + weakArr[day];


// 定义一个函数，用于更新时间
function updateTime() {
    // 获取当前时间
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();

    // 格式化时间，确保每个部分都是两位数
    hours = hours < 10 ? '0' + hours : hours;
    minutes = minutes < 10 ? '0' + minutes : minutes;
    seconds = seconds < 10 ? '0' + seconds : seconds;

    // 将时间写入到HTML元素中
    document.getElementById('timeDisplay').textContent = hours + ':' + minutes + ':' + seconds;
    var welcome;
    if (hours >= 6 && hours < 12) {
        welcome = "早上好！"
    }else if (hours >= 12 && hours < 18) {
        welcome = "下午好！"
    }else {
        welcome = "晚上好！"
    }
    // 将问候语写入到HTML元素中
    document.getElementById('welcome').textContent = welcome;
}

// 每秒调用一次updateTime函数
setInterval(updateTime, 1000);

// 页面加载时立即更新一次时间
updateTime();